#ifndef HISTORYMESSAGEWIDGET_H
#define HISTORYMESSAGEWIDGET_H

#include <QDialog>
#include <QWidget>
#include <QGridLayout>
#include <QRadioButton>
#include <QLineEdit>
#include <QPushButton>
#include <QLabel>
#include <QDateTimeEdit>
#include <QScrollArea>
#include <QScrollBar>
#include <QVBoxLayout>
#include "model/data.h"
#include "debug.h"

using model::MessageInfo;

//////////////////////////////
/// 单个历史消息元素
//////////////////////////////
class HistoryItem : public QWidget
{
    Q_OBJECT
public:
    HistoryItem();

    static HistoryItem *makeHistoryItem(const MessageInfo &msg);
};

//////////////////////////////
/// 搜索历史消息界面
//////////////////////////////
class HistoryMessageWidget : public QDialog
{
    Q_OBJECT
public:
    HistoryMessageWidget(QWidget *parent = nullptr);

private:
    void initScrollArea();

    void addHistoryMsg(const MessageInfo &msg);
    void clear();

private:
    QGridLayout *_layout;

    QRadioButton *_keyRadioBtn;
    QRadioButton *_timeRadioBtn;

    QLineEdit *_searchEdit;
    QPushButton *_searchBtn;

    QLabel *_begTag;
    QLabel *_endTag;
    QDateTimeEdit *_begTimeEdit;
    QDateTimeEdit *_endTimeEdit;

    QScrollArea *_scrollArea;
    QWidget *_container;
    QVBoxLayout *_vlayout;
};

#endif // HISTORYMESSAGEWIDGET_H
